package com.class05.ioc_04;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class JavaBean {
//    <bean id class
//    方案1：直接赋值
//    方案2：注解赋值 @Value注解  直接赋值  读取外部配置文件
//    默认值语法  @Value("${key:value默认值}")
    private String name = "张三";
    @Value("19")
    private int age;
    @Value("${class05.username:admin}")
    private String username;
    @Value("${class05.password}")
    private String password;

    @Override
    public String toString() {
        return "JavaBean{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
